package com.example.hudongwx.myclass0719application.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

import com.example.hudongwx.myclass0719application.API;
import com.example.hudongwx.myclass0719application.R;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

/**
 * Created by hudongwx on 16-10-26.
 */

@ContentView(R.layout.fragyure)
public class FragYuRe extends Fragment {
  @ViewInject(R.id.fragyure__tv_titile)
  private TextView  textView;
   @ViewInject(R.id.fragyure_webview)
     private WebView webView;

    private View view;




    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
         if (null==view){
             view=x.view().inject(this,inflater,container);
             webView.setWebViewClient(new WebViewClient(){
                 @Override
                 public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                     return true;
                 }
             });
             webView.setWebChromeClient(new WebChromeClient(){
                 @Override
                 public void onReceivedTitle(WebView view, String title) {
                       textView.setText(title);

                 }
             });
             webView.getSettings().setJavaScriptEnabled(true);
             webView.loadUrl(API.fragyure_hot);
         }
        return view;
    }
    @Event(R.id.frayure_iamgeview_refresh)
    private void fresh(View view){
         webView.reload();
    }

}
